<template>
  <div class="app-container">
    <el-form size="small" :inline="true">
      <el-form-item label="关键字">
        <!--  @keyup.enter.native="handleQuery" -->
        <el-input placeholder="请输入房间号，床号，使用者" />
      </el-form-item>
      <el-form-item>
        <el-date-picker type="date" placeholder="请选择警报日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-select v-model="alarmcontent" placeholder="请选择警报类型">
          <el-option
            v-for="item in alarmoptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="alarmList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="机构名" align="center" prop="agencyname" />
      <el-table-column label="房间号" align="center" prop="room" />
      <el-table-column label="床号" align="center" prop="bed" />
      <el-table-column label="使用者姓名" align="center" prop="username" />
      <el-table-column label="报警内容" align="center" prop="content" />
      <el-table-column label="发生时间" align="center" prop="time" />
      <el-table-column label="处理状态" align="center" prop="status" />
    </el-table>

    <pagination
      :total="total"
      :page.sync="pageNum"
      :limit.sync="pageSize"
      @pagination="getalarmlist"
    />
  </div>
</template>

<script>
import { getalarmlistApi } from "@/api/alarm";
export default {
  computed: {
    ...mapGetters(["agencyId", "agencystring"]),
  },
  data() {
    return {
      loading: false,
      total: 0,
      pageNum: 1,
      pageSize: 20,
      alarmcontent: undefined,
      alarmoptions: [],
      alarmList: [
        {
          agencyname: "はに町_ちとせ小町",
          room: "は 12",
          bed: "",
          username: "柳田陽一",
          content: "赤:短期離床",
          time: "2024-07-16 15:33:20",
          status: "未処理",
        },
      ],
    };
  },
  created() {
  },
  methods: {
    /** 获取警报列表  */
    async getalarmlist() {
      const newlist = [];
      this.loading = true;
      const { data } = await getalarmlistApi({
        agencyIds: this.agencystring,
        pageSize: 10,
        pageNumber: 1,
      });
      data.dataRows.forEach((item) => {
        this.newlist.push({
          agencyname: item.customer.agencyName,
          room: item.customer.roomNo,
          bed: item.customer.bedNo,
          username: item.customer.name,
          content: item.title,
          time: item.measureDatetime,
          status: item.handleStatus == 0 ? "未处理" : "已处理",
        });
      });
      this.alarmList = newlist;
      this.total = data.totalRecords;
      this.loading = false;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.open = true;
      this.title = "添加使用者";
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$modal
        .confirm("是否确认删除数据项？")
        .then(function () {})
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
  },
};
</script>

<style></style>
